package Adapter;

import javax.swing.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

/**
 * @Description:定义适配器类，这是一个抽象类，是在最终实现类和接口之间的一个过渡类。
 * @Author:AMark
 * @Date: 10/23/2023
 */
//定义我的适配器，虚假实现WindowListener监听器类
public class MyAdapter implements WindowListener {
    public void windowActivated(WindowEvent e) {}
    public void windowClosing(WindowEvent e) {}
    public void windowClosed(WindowEvent e) {}
    public void windowDeactivated(WindowEvent e) {}
    public void windowDeiconified(WindowEvent e) {}
    public void windowIconified(WindowEvent e) {}
    public void windowOpened(WindowEvent e) {}
}
class MyWindow extends MyAdapter {
    //这里只实现一个方法
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setSize(300,200);
        frame.setVisible(true);
        frame.addWindowListener(new MyWindow());
    }
    @Override
    public void windowClosing(WindowEvent e) {
        System.out.print("hhh");
        System.exit(0);
    }
}
